<?php
/**
 * Created by PhpStorm.
 * User: wuxiang
 * Date: 2016/8/30
 * Time: 13:46
 */

namespace Tags\Controller;

use Common\Controller\AdminbaseController;
use Common\Libiary\ArrayPage;
use Common\Libiary\BaseApiHttp;
use Common\Libiary\FileExcel;
use Common\Libiary\importFile;
use Common\Libiary\Uploadify;
use Common\Libiary\WechatMaterial;

class TagsController extends AdminbaseController
{

    public $data = [];
    public $arr = [];
    public $res = [];
    public $rest = [];
    public $result = [];
    public $list;
    public $fanAcount;
    public $url;
    public $setUrl;
    public $page;
    private $secretusernew = '**9noww!@mwbyd&&';

    /**
     * 获取城市标签列表
     */
    function index()
    {

        $wechat = new WechatMaterial();
        $this->result = $wechat->getTagsList();

        //分页加搜索
        $keywords = I('keywords', '');

        $count = count($this->result);

        $arrPage = new ArrayPage($this->result, 20, U('Tags/index'), 0);

        if ($keywords) {

            $res = array_filter($this->result, function ($e) use ($keywords) {
                return ($e['name'] == $keywords);
            });

        } else {

            $res = $arrPage->getData();

        }

        $pageList = $arrPage->getShow();

        $this->assign('list', $res);

        $this->assign('count', $count);

        $this->assign('keywords', $keywords);

        $this->assign("pager", $pageList);

        $this->display();
    }

    //导出

    function importFile()
    {
        $postFile = I('post', '1');
        if ($postFile) {
            $info = new FileExcel();
            $wechat = new WechatMaterial();
            $xlsData = $wechat->getTagsList();
            $info->export($xlsData, '标签下粉丝数' . date('Y-m-d H:i:s'), '标签下粉丝数');
        }
    }
}